"""
@Author    : ghenyar
@Time      : 2025/8/28 12:54
@File      : exceptions.py
@Desc      : 
"""
from typing import Any


class BasesException(Exception):
    """基础异常类"""

    def __init__(
            self,
            code: int = 500,
            message: str = "服务器内部错误",
            data: Any = None,
            status: int = -1,
    ):
        self.code = code
        self.message = message
        self.data = data
        self.status = status
        super().__init__(message)


class AuthException(BasesException):
    """认证相关异常"""

    def __init__(
            self,
            message: str = "认证失败",
            data: Any = None
    ):
        super().__init__(code=401, message=message, data=data)


class ForbiddenException(BasesException):
    """权限相关异常"""

    def __init__(
            self,
            message: str = "无权限访问",
            data: Any = None
    ):
        super().__init__(code=403, message=message, data=data)


class NotFoundException(BasesException):
    """资源不存在异常"""

    def __init__(
            self,
            message: str = "资源不存在",
            data: Any = None
    ):
        super().__init__(code=404, message=message, data=data)


class ValidationException(BasesException):
    """参数验证异常"""

    def __init__(
            self,
            message: str = "参数验证失败",
            data: Any = None
    ):
        super().__init__(code=422, message=message, data=data)


class BusinessException(BasesException):
    """业务逻辑异常"""

    def __init__(
            self,
            message: str = "业务处理失败",
            data: Any = None,
            status: int = -1,
            code: int = 400,
    ):
        super().__init__(code=code, message=message, data=data, status=status)


class HTTPException(BasesException):
    def __init__(
            self,
            message: str = "业务处理失败",
            data: Any = None
    ):
        super().__init__(code=400, message=message, data=data)
